const EventEmitter = require('events')
class myEvent extends EventEmitter{

}
var index = 0;
const ce = new myEvent()

ce.on('test',()=>{
    console.log('this is a eventEmitter')
})

var timer = setInterval(()=>{
    if(index++>20){
        clearInterval(timer)
    }
    ce.emit('test')
},500)